#include <stdio.h>
#include <stdlib.h>
#include "patterntest.h"
#include "makepattern.h"

void vPrintHexData( unsigned char *data , int len , char *tital )
{
	int i ;
	printf( "\n%s :\n" , tital ) ;
	for( i=0 ; i< len ; i++ )
	{
		if(( i!=0 )&&(i%8 == 0 )) printf( " " ) ;
		if(( i!=0 )&&(i%16 == 0 )) printf( "\n" ) ;
		printf( "%02x " , (int)data[i] ) ;
	}
}


#include "aes.h"
unsigned char test1_key1[] = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
                            0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c, 
                            0x39, 0x7e, 0x15, 0x33, 0x44, 0x55, 0xd2, 0xa6,
                            0xab, 0xf7, 0x22, 0x88, 0x09, 0x22, 0x11, 0x3c};



unsigned char test1_key2[] = {0x39, 0x25, 0x84, 0x1d, 0x02, 0xdc, 0x09, 0xfb,
                           0xdc, 0x11, 0x85, 0x97, 0x19, 0x6a, 0x0b, 0x32,
 			               0x32, 0x43, 0xf6, 0xa8, 0x88, 0x5a, 0x30, 0x8d,
                           0x31, 0x31, 0x98, 0xa2, 0xe0, 0x37, 0x07, 0x34 }; 
void vAes_test(void)
{
	unsigned char data[16] ;
	unsigned char DncodedData[16];
	int i ;
	for( i=0 ; i<16 ; i++ )
		data[i] = 0x4 + i ;
	vAes_SetKey( BIT256, test1_key1 );
	aes_ecb_encrypt( data, DncodedData , 16 ) ;
	
	printf("src data\n");
	for( i =0 ; i<16 ; i++ )
	{
		printf("%02x " , data[i] ) ;
	}
	printf("\n");
	
	printf("tar data\n");
	for( i =0 ; i<16 ; i++ )
	{
		printf("%02x " , DncodedData[i] ) ;
	}
	system( "pause" );
	printf("\n");
}


int main(int argc, char *argv[])
{
	char cSelect[10];
	int iSelect ;
	
	printf( "Please select mode : \n0:test all vec.  \n1:make vec. \n" ) ;
	scanf( "%s" , cSelect ) ;
	iSelect = atoi( cSelect ) ;
	
	switch( iSelect )
	{
		case 0 :
			iPatternTest_Test();
			break ;
		case 1:
			vMakePattern();
			break ;
		case 2:
			vAes_test();
			break ;
		default :
			printf( "No this item ! \n" ) ;			
	}
		
	return 0 ;
}
